﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Reflection;

namespace BulldogCMS.Core.Runtime.Modules
{
    public abstract class BaseModuleAreaProvider
    {
        public System.Web.Mvc.IController CreateControllerFromCurrentAssembly(System.Web.Routing.RequestContext requestContext, string controllerName, Assembly currentAssembly)
        {
            string assemblyName = currentAssembly.GetName().Name;
            Type controllerType = currentAssembly.GetType(string.Format("{0}.Controllers.{1}Controller", assemblyName, controllerName), false, true);
            if (controllerType != null)
            {
                BaseModuleController controller = controllerType.Instantiate<BaseModuleController>();
                controller.Init(currentAssembly);
                return controller;
            }
            return null; //new Controllers.HomeController();
        }

    }
}